export const getObjectValueByPath = (obj: any, path: string) => {
  const keys = path.split('.');
  let value = obj;
  for (let key of keys) {
    value = value[key];
    if (value === undefined) {
      break;
    }
  }
  return value;
};

//对多级key进行赋值 key字符串实例:config.is_use
export const setObjectValueByPath = (obj: any, path: string, value: any) => {
  const keys = path.split('.');
  let currentObj = obj;
  for (let i = 0; i < keys.length - 1; i++) {
    const key = keys[i];
    if (!currentObj[key]) {
      currentObj[key] = {};
    }
    currentObj = currentObj[key];
  }
  const lastKey = keys[keys.length - 1];
  currentObj[lastKey] = value;
};
